//
//  RangeEditViewController.m
//  ShangPiBao
//
//  Created by chirui on 2017/10/25.
//  Copyright © 2017年 Shui. All rights reserved.
//

#import "RangeEditViewController.h"
#import "SZTextView.h"

@interface RangeEditViewController ()

@property (nonatomic,strong) SZTextView * sztTextView;

@end

@implementation RangeEditViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor =[UIColor groupTableViewBackgroundColor];
    
    self.navigationItem.titleView = [TopLabel withLabelWithLabelText:@"经营范围"];
    [self creatTextView];
    
//    self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithIcon:@"icon_nav_return" target:self action:@selector(back)];
}

-(void)back{
    
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)creatTextView {
    
    
    self.sztTextView =[[SZTextView alloc]initWithFrame:CGRectMake(0, 10, WIDTH, 300)];
    self.sztTextView.placeholder = @"请输入经营范围~";
    self.sztTextView.text = self.messageStr;
    self.sztTextView.font =[UIFont systemFontOfSize:15];
    [self.view addSubview:self.sztTextView];
    
    UIButton * sumBtn =[UIButton buttonWithType:UIButtonTypeSystem];
    [sumBtn setTitle:@"确认" forState:UIControlStateNormal];
    sumBtn.backgroundColor =[UIColor blackColor];
    [sumBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    sumBtn.frame = CGRectMake(60,350 , WIDTH-120, 45);
    sumBtn.layer.cornerRadius= 22.5f;
    sumBtn.layer.masksToBounds = YES;
    [sumBtn addTarget:self action:@selector(sumBtnClick) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:sumBtn];
    
}

-(void)sumBtnClick {
    
    [self.sztTextView resignFirstResponder];
    
   
    
    if (self.sztTextView.text.length<=0) {
        
        [MBProgressHUD showMessag:@"请填写反馈意见" withDelay:0 toView:self.view withMode:MBProgressHUDModeText hideWithDelay:1.5];
        
        return;
    }else {
        
         self.rangeBlock(self.sztTextView.text);
         [self.navigationController popViewControllerAnimated:YES];
//        [self requestMessageForNet];
    }
    
}

//-(void)requestMessageForNet{
//    
//    
//    NSDictionary * dic = @{@"user_id":USER_DEFAULTGet(@"user_id"),
//                           @"token":USER_DEFAULTGet(@"token"),
//                           @"content":self.sztTextView.text
//                           };
//    SHuiMBhubNoTimeStr(@"正在提交...");
//    [PostNetWorking postNetWorkingStr:RequestUrlStr(makeAdvise_message_api) andparameters:dic Success:^(id responseObject) {
//        SHuiMBHidleYes;
//        if (codeSucess) {
//            SHuiMBhudTextTimeStr(@"提交成功！");
//            
//            dispatch_async(dispatch_get_global_queue(0, 0), ^{
//                dispatch_after(dispatch_time(DISPATCH_TIME_NOW , (1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(),^{
//                    
//                    [self.navigationController popViewControllerAnimated:YES];
//                });
//            });
//            
//        }else {
//            
//            SHuiMBhudTextTimeStr(responseObject[@"mark"]);
//        }
//        
//    } failed:^(NSError *error) {
//        SHuiMBHidleYes;
//        SHuiMBhudTextTimeStr(@"网络错误，请检查网络");
//        
//    }];
//    
//}

@end
